<?php
class lib_url{
	static function _do($uri=null){
		return new lib_url($uri);
	}
	
	private $url;
	
	function __construct($uri=null){
		if(empty($uri)){
			$uriArr[0]=m()->status['module'].':'.m()->status['action'];
		}else{
			$uriArr = explode('?',$uri);
		}
		$moduleArr = explode(':',$uriArr[0]);
		$module=$moduleArr[0];
		$action = $moduleArr[1];
		$query = $uriArr[1];
		
		$this->url = "./?m=$module&a=$action&$query";
	}
	
	function __toString(){
		return $this->url;
	}
	
	function redirect(){
		header('Location: '.$this->url);
	}
}